#ifndef __THREAD_POOL___
#define __THREAD_POOL___
#include "my_header.h"
#include "tidArr.h"
#include "taskQueue.h"
/* #include"sendMsg.h" */
/* #include"worker_sql_tools.h" */
#include"dirStack.h"
#include"analysis.h"
#include"transfile.h"
#include "strTok.h"
#include "canalysis_hash.h"
#include "sendMsg.h"
//声明枚举类型
enum cmd_type{
    REGISTER,//注册
    LOGIN,//登录
    LS,
    CD,
    PWD,
    REMOVE,
    MKDIR,
    PUTS,
    GETS,
    RMDIR,
    OTHER,
};
//声明全局变量
extern MYSQL* conn;  // 声明全局变量
// 声明全局变量
extern const char* host;
extern const char* user;
extern const char* password;
extern const char* database;



typedef struct threadPool_s {
    //工人线程的信息
    tidArr_t tidArr;
    //任务队列
    taskQueue_t taskQueue;
    Canalysis_t *command;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
    int exitFlag;//退出标志位
} threadPool_t;
void *threadFunc(void*argc);
int makeWorker(threadPool_t*pthreadPool);
int putsFile(const char* finalPath,Canalysis_t* canalysis,int netfd);
int getsFile(const char* finalPath,Canalysis_t* canalysis,int netfd);
int threadPoolInit(threadPool_t *pthreadPool,int workerNum);
int makeWorker(threadPool_t *pthreadPool);
int epollAdd(int epfd, int fd);
int epollDel(int epfd, int fd);
int tcpInit(char *ip, char *port);
int transfile(int sockfd);
//分割字符串
int strToken(const char *command,userInfo_t *userInfo);
//数据库连接
MYSQL *initDatabaseConnect();
char * createRandomSalt();

//注册用户
int userIsExit(MYSQL *mysql,userInfo_t *userInfo,user_t *user);
int registerUser(MYSQL *mysql,userInfo_t *userInfo,user_t *user);
int userSalt(MYSQL *mysql,userInfo_t *userInfo,user_t *user);
//根据用户名和密码生成token
char* generate_token(const char* username, const char* password);
#endif

